﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.IO;

namespace BDM
{
    class SetData
    {
        private static Database db = new Database();

        public static void UpdatePrice(string Van, string Naar, string Prijs, bool Spits)
        {
            string sSoort = "prijs";

            if (Spits == true)
            {
                sSoort = "spitsPrijs";
            }

            try
            {
                db.PutQuery("UPDATE trajecten SET " + sSoort + "='" + Prijs + "' WHERE van=" + Van + " AND naar=" + Naar);
            }
            catch (Exception){}
        }

        public static void RemoveOldFiles()
        {
            try
            {
                if (!Directory.Exists("idfiles"))
                {
                    Directory.CreateDirectory("idfiles");
                }
                List<string> list = new List<string>();
                foreach (string sPathFile in Directory.GetFiles("idfiles"))
                {
                    string filename = Path.GetFileName(sPathFile);
                    File.Delete(@"idfiles\" + filename);
                }
            }
            catch { }
        }

        public static void SetTransaction(string AutoID, string Tijdstip, string Prijs)
        {
            try
            {
                db.PutQuery("INSERT INTO transacties (autoId, tijdstip, prijs) VALUES ('" + AutoID + "', '" + Tijdstip + "', '" + Prijs + "')");
            }
            catch (Exception) {}
        }
    }
}
